print_tmp equ tmp1

_showmsg
	movlw 0x80
	call lcd_cmd
	call _print
	movlw 0xC0
	call lcd_cmd
	movlw 16
	movwf strlo
	movlw ' '
	call lcd_char
	decfsz strlo
	goto $-3
	return

_print
	call string
	andlw 0xFF
	btfsc STATUS, Z
	return
	call lcd_char
	incf strlo
	btfsc STATUS, Z
	incf strhi
	goto _print

printnum8
	call dec8
	movwf print_tmp
	swapf print_tmp, W
	andlw 0x0F
	addlw '0'
	call lcd_char
	movf print_tmp, W
	andlw 0x0F
	addlw '0'
	call lcd_char
	return

printhex8
	movwf print_tmp
	swapf print_tmp, W
	andlw 0x0F
	call printhex4
	movf print_tmp, W
	andlw 0x0F
	call printhex4
	return

printhex4
	addlw 0xFF-9
	btfsc STATUS, C
	addlw 'A'-'9'-1
	addlw '0'+10
	call lcd_char
	return

dec8 ; sacrifice some memory words for fast binary to BCD
	movwf lcd_tmp
	movlw ($>>8)
	movwf PCLATH
	movf lcd_tmp, W
	addlw 3
	addwf PCL, W
	btfsc STATUS, C
	incf PCLATH
	movwf PCL
	retlw 0x00
	retlw 0x01
	retlw 0x02
	retlw 0x03
	retlw 0x04
	retlw 0x05
	retlw 0x06
	retlw 0x07
	retlw 0x08
	retlw 0x09
	retlw 0x10
	retlw 0x11
	retlw 0x12
	retlw 0x13
	retlw 0x14
	retlw 0x15
	retlw 0x16
	retlw 0x17
	retlw 0x18
	retlw 0x19
	retlw 0x20
	retlw 0x21
	retlw 0x22
	retlw 0x23
	retlw 0x24
	retlw 0x25
	retlw 0x26
	retlw 0x27
	retlw 0x28
	retlw 0x29
	retlw 0x30
	retlw 0x31
	retlw 0x32
	retlw 0x33
	retlw 0x34
	retlw 0x35
	retlw 0x36
	retlw 0x37
	retlw 0x38
	retlw 0x39
	retlw 0x40
	retlw 0x41
	retlw 0x42
	retlw 0x43
	retlw 0x44
	retlw 0x45
	retlw 0x46
	retlw 0x47
	retlw 0x48
	retlw 0x49
	retlw 0x50
	retlw 0x51
	retlw 0x52
	retlw 0x53
	retlw 0x54
	retlw 0x55
	retlw 0x56
	retlw 0x57
	retlw 0x58
	retlw 0x59
	retlw 0x60
	retlw 0x61
	retlw 0x62
	retlw 0x63
	retlw 0x64
	retlw 0x65
	retlw 0x66
	retlw 0x67
	retlw 0x68
	retlw 0x69
	retlw 0x70
	retlw 0x71
	retlw 0x72
	retlw 0x73
	retlw 0x74
	retlw 0x75
	retlw 0x76
	retlw 0x77
	retlw 0x78
	retlw 0x79
	retlw 0x80
	retlw 0x81
	retlw 0x82
	retlw 0x83
	retlw 0x84
	retlw 0x85
	retlw 0x86
	retlw 0x87
	retlw 0x88
	retlw 0x89
	retlw 0x90
	retlw 0x91
	retlw 0x92
	retlw 0x93
	retlw 0x94
	retlw 0x95
	retlw 0x96
	retlw 0x97
	retlw 0x98
	retlw 0x99
